<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>申报商户</title>

    <link rel="stylesheet" href="../../../bangnuo/css/operation/add_merchants_new.css">

    <script src="../../../bangnuo/vue/vue.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="../../../bangnuo/bootstrap/js/jquery-3.4.1.js"></script>
    <script src="../../../bangnuo/vue/axios.min.js"></script>
    <script type="module" src="./js/config/public.js"></script>
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 158px;
            height: 158px;
            line-height: 158px;
            text-align: center;
        }
        .avatar {
            width: 158px;
            height: 158px;
            display: block;
        }
        .upload-image-class{
            width: 50%;float:left;
        }
    </style>
</head>
<body>
<div id="app">
    <!--布局容器-->
    <div class="container-fluid" style="width: 80%;margin: 0 auto; background-color: white;padding:20px 50px">
        <!--进度条展示-->
        <div class="row" id="jindu">
            <ul style="display:flex; align-items: center">
                <li class="aline">

                </li>
                <li class="step">
                    <p>基本信息</p>
                </li>
                <li class="aline">
                    <span></span>
                </li>
                <li class="step step-6">
                    <p>结算信息</p>
                </li>
                <li class="aline">
                    <span></span>
                </li>
                <li class="step step-7">
                    <p>店铺信息</p>
                </li>
                <li class="aline">
                    <span></span>
                </li>
                <li class="step step-8">
                    <p>资质信息</p>
                </li>
                <li  class="aline">
                    <span></span>
                </li>
                <li class="step step-9">
                    <p>上传资质</p>
                </li>
                <li class="alineg">
                    <span></span>
                </li>
                <li class="step step-5">
                    <p>保单完成</p>
                </li>
                <li class="alineg">
                    <span></span>
                </li>
            </ul>
        </div>
        <!--内容头展示-->
        <div class="row jiben-title-text">
            上传资质
        </div>
        <!--内容-->
        <div class="row input-content">
            <div class="container input-container-content">
            </div>
            <el-form v-model="formData" label-position="right" label-width="100px">
                    <el-col :span="24">
                        <div v-if="form.commercialTenantDetails.incomType !=1" class="upload-image-class">
                            <div>营业执照照片</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureBusiness"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureBusiness" :src="imgList.permissionsPictureBusiness" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <!--<div class="upload-image-class">
                            <div>税务登记证照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureTaxAuthority"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    &lt;!&ndash;用于上传图片预览&ndash;&gt;
                                    <img v-if="imgList.permissionsPictureTaxAuthority" :src="imgList.permissionsPictureTaxAuthority" class="avatar">
                                    &lt;!&ndash;用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片&ndash;&gt;
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>-->

                        <!--<div class="upload-image-class">
                            <div>组织机构照/单位证 明函</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureInstitutionalFramework"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    &lt;!&ndash;用于上传图片预览&ndash;&gt;
                                    <img v-if="imgList.permissionsPictureInstitutionalFramework" :src="imgList.permissionsPictureInstitutionalFramework" class="avatar">
                                    &lt;!&ndash;用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片&ndash;&gt;
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>-->

                        <div v-if="form.commercialTenantDetails.incomType==1" class="upload-image-class">
                            <div>申请人身份证正面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureProposerPositive"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureProposerPositive" :src="imgList.permissionsPictureProposerPositive" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType==1" class="upload-image-class">
                            <div>申请人身份证反面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureProposerReverse"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureProposerReverse" :src="imgList.permissionsPictureProposerReverse" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType !=1" class="upload-image-class">
                            <div>法人身份证正面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureCardPositive"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureCardPositive" :src="imgList.permissionsPictureCardPositive" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType !=1" class="upload-image-class">
                            <div>法人身份证反面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureProposerReverse"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureProposerReverse" :src="imgList.permissionsPictureProposerReverse" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div  class="upload-image-class">
                            <div>门头照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureDoor"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureDoor" :src="imgList.permissionsPictureDoor" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>


                        <div class="upload-image-class">
                            <div>场景照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureStore"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureStore" :src="imgList.permissionsPictureStore" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div  class="upload-image-class">
                            <div>收银台照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureCheckstand"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureCheckstand" :src="imgList.permissionsPictureCheckstand" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType!=1 && form.commercialTenantDetails.stlSign==1 && form.commercialTenantDetails.settlementParty==2" class="upload-image-class">
                            <div>结算人身份证正面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureIcrpPositive"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureIcrpPositive" :src="imgList.permissionsPictureIcrpPositive" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType!=1 && form.commercialTenantDetails.stlSign==1 && form.commercialTenantDetails.settlementParty==2" class="upload-image-class">
                            <div>结算人身份证反面照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureIcrpReverse"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureIcrpReverse" :src="imgList.permissionsPictureIcrpReverse" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div class="upload-image-class">
                            <div>银行卡照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureBank"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureBank" :src="imgList.permissionsPictureBank" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>


                        <div v-if="form.commercialTenantDetails.incomType !=1 && form.commercialTenantDetails.stlSign==0 && form.commercialTenantDetails.settlementParty==0" class="upload-image-class">
                            <div>开户行许可证照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureBankOfDeposit"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureBankOfDeposit" :src="imgList.permissionsPictureBankOfDeposit" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType ==1" class="upload-image-class">
                            <div>结算人手持证件照</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureHandheld"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureHandheld" :src="imgList.permissionsPictureHandheld" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div  class="upload-image-class">
                            <div>商户协议</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureMerchantsDeal"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureMerchantsDeal" :src="imgList.permissionsPictureMerchantsDeal" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>


                        <div  class="upload-image-class">
                            <div>商户信息表</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureBusinessInformation"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureBusinessInformation" :src="imgList.permissionsPictureBusinessInformation" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                        <div v-if="form.commercialTenantDetails.incomType!=1 && form.commercialTenantDetails.stlSign==1 && form.commercialTenantDetails.settlementParty==2" class="upload-image-class">
                            <div>授权结算书</div>
                            <el-form-item label="">
                                <el-upload
                                        class="avatar-uploader"
                                        action="/upload/img2/permissionsPictureBusinessAuthorization"
                                        :auto-upload="autoUpload"
                                        name="file"
                                        :show-file-list="false"
                                        :on-success="handleAvatarSuccess"
                                        :before-upload="beforeAvatarUpload">
                                    <!--用于上传图片预览-->
                                    <img v-if="imgList.permissionsPictureBusinessAuthorization" :src="imgList.permissionsPictureBusinessAuthorization" class="avatar">
                                    <!--用于展示上传图标，当imageUrl为null时，就展示空白，当imageUrl有了值，就会展示指向该地址的图片-->
                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                </el-upload>
                            </el-form-item>
                        </div>

                    </el-col>
            </el-form>
            <div class=" submit-button">
                <el-button type="primary" @click="breakButton">上一步</el-button>
                <el-button type="primary" @click="savaSubmit">提交</el-button>
            </div>
        </div>
    </div>
</div>
<script type="module">
    import bnApi from './js/config/public.js';
    var vue = new Vue({
        el: '#app',
        data: {
            autoUpload: true,//图片自动上传
            imageUrl: null,//模型数据，用于上传图片完成后图片预览
            formData: {},//表单数据
            id:'',
            imgList:{
                permissionsPictureBusiness:'',//营业执照
                permissionsPictureTaxAuthority:'',//税务登记
                permissionsPictureInstitutionalFramework:'',//组织机构照/单位证 明函
                permissionsPictureCardPositive:'',//法人身份证正面照
                permissionsPictureCardReverse:'',//法人身份证反面照
                permissionsPictureDoor:'',//门头照
                permissionsPictureStore:'',//场景照
                permissionsPictureCheckstand:'',//收银台照
                permissionsPictureIcrpPositive:'',//结算人身份证正面照
                permissionsPictureIcrpReverse:'',//结算人身份证反面照
                permissionsPictureBank:'',//银行卡照
                permissionsPictureBankOfDeposit:'',//开户行许可证照
                permissionsPictureHandheld:'',//法人手持证件照
                permissionsPictureMerchantsDeal:'',//商户协议
                permissionsPictureBusinessInformation:'',//商户信息
                permissionsPictureBusinessAuthorization:'',//授权结算书
                permissionsPictureProposerPositive:'',//申请人身份证正面
                permissionsPictureProposerReverse:'',//申请人身份证反面
            },
            form:{}
        },
        methods: {
            breakButton:function () {
                console.log("执行后退方法")
                location.href = "./add_merchants_new3.html?id="+this.id;
            },
            savaSubmit:function(){
                bnApi.requestPost("/commercial/updateImage/"+this.id,this.imgList).then(res=>{
                    if(res.success){
                        this.form.commercialTenant.step = 4;
                        bnApi.requestPost('/commercial/addNew',this.form).then(res=>{
                            if(res.success){
                                this.id = res.object.id;
                                //进行跳转进入下一步
                                location.href='add_merchants_new5.html?id='+this.id;
                            }
                        });
                    }
                });
            },
            handleAvatarSuccess(res, file) {
                //给模型数据赋值，进行图片的预览
                if (res.success) {
                    this.imgList[res.object.name] = res.object.webPath;
                } else {

                }
            },
            //上传图片之前执行,只是对选中的图片的后缀名进行校验
            //file就是上传的文件
            beforeAvatarUpload(file) {
                // 可以在tomcat的conf的web.xml中找到相对应的文件类型
                var isJPG = file.type === 'image/jpeg'||'image/gif'||'image/png';

                var isLt2M = file.size / 1024 / 1024 < 4;
                if (!isLt2M) {
                    this.$message.error('上传套餐图片大小不能超过 4MB!');
                }
                return isJPG && isLt2M;
            },
            getQueryVariable:function (variable) {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == variable){return pair[1];}
                }
                return(false);
            },
            findById:function () {
                this.id = this.getQueryVariable("id");
                console.log("传过来中的id:",this.id);
                if(this.id == ''){
                    return;
                }
                bnApi.requestGet('/commercial/findByIdNew/'+this.id).then(res=>{
                    if(res.success){
                        //此代码不写，插入可能失败
                        this.form = res.object
                        console.log("form值：",this.form)
                    }
                });
            },
            findImgById(){
                bnApi.requestGet("/commercial/findImgById/"+this.id).then(res=>{
                    if(res.success){
                        this.imgList = res.object;
                    }
                });
            }
        },
        mounted(){
            this.id = this.getQueryVariable("id");
            console.log("this.id",this.id)
            this.findById();
            this.findImgById();
        },

    })
</script>
</body>


</html>